<?php

class ImageController extends Project_Controller{
	
    public function indexAction(){
    	if($this->_request->isPost()){
			$name = 'image_field_name';
    		if(Frogg_Image::isImage($name)){
	    		$image = new Frogg_Image($name);
	    		$img_1 = $image->save();
	    		$img_2 = $image->saveFixedHeight(100);
	    		$img_3 = $image->saveFixedWidth(200);
	    		$img_4 = $image->saveMaxWidthHeight(200, 50);
	    		$img_5 = $image->saveThumb(100, 100);
	    		
	    		echo '<ul>';
		        echo '<li><b> public save()</b> <img src="/i/'.$img_1.'"/></li>';
		        echo '<li><b> public saveFixedHeight(100)</b> <img src="/i/'.$img_2.'"/></li>';
		        echo '<li><b> public saveFixedWidth(200)</b> <img src="/i/'.$img_3.'"/></li>';
		        echo '<li><b> public saveMaxWidthHeight(200, 50)</b> <img src="/i/'.$img_4.'"/></li>';
		        echo '<li><b> public saveThumb(100, 100)</b> <img src="/i/'.$img_5.'"/></li>';
		        echo '<li><b><a href="/image/download?img='.$img_1.'">download link | downloadAction()<a></b></li>';
		        echo '</ul>';
    		} else {
	    		echo '<ul>';
		        echo '<li>Not an Image</li>';
		        echo '</ul>';
    			echo '';
    		}
    	} else {
	    	echo '<h1>Send an Image to see Frogg_Image working</h1>';
    		echo '<form method="post" action="" enctype="multipart/form-data">
    		<input type="file" name="image_field_name"/>
    		<input type="submit"/>
    		</form>';
    	}
    	
    	echo '<h1>Class Frogg_Image</h1>';
        $image = new Frogg_Time_Time();
        echo '<ul>';
        echo '<li><b> static isImage($string)</b></li>';
        echo '</ul>';
        
        echo '<ul>';
        echo '<li><b> public __construct($name, $path=false)</b></li>';
        echo '<li><b> public download()</b></li>';
        echo '<li><b> public save($path=\'i\')</b></li>';
        echo '<li><b> public saveFixedWidth($width, $path=\'i\')</b></li>';
        echo '<li><b> public saveFixedHeight($height, $path=\'i\')</b></li>';
        echo '<li><b> public saveMaxWidthHeight($width, $height, $path=\'i\')</b></li>';
        echo '<li><b> public saveThumb($width, $height, $path=\'i\'):</b></li>';
        echo '<li><b> static isImage($string)</b></li>';
        echo '</ul>';
    	
        die;
    }
	
    public function downloadAction(){
    	$file_name = $this->_request->getParam('img');
    	$image = new Frogg_Image($file_name,'i');
    	$image->download();
    }

}